// $ANTLR 3.3 Nov 30, 2010 12:45:30 C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g 2012-06-21 13:50:55

    package org.moflon.moca.rule.parser; 


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class RuleParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "WHITESPACE", "TO", "DONTCARE", "THIS", "SEPARATOR", "NEWLINE", "EMPTY", "RULE", "BEFORE", "AFTER", "ROW", "DONTCARE_FIELD", "THIS_FIELD", "MAIN", "EMPTY_FIELD"
    };
    public static final int EOF=-1;
    public static final int WHITESPACE=4;
    public static final int TO=5;
    public static final int DONTCARE=6;
    public static final int THIS=7;
    public static final int SEPARATOR=8;
    public static final int NEWLINE=9;
    public static final int EMPTY=10;
    public static final int RULE=11;
    public static final int BEFORE=12;
    public static final int AFTER=13;
    public static final int ROW=14;
    public static final int DONTCARE_FIELD=15;
    public static final int THIS_FIELD=16;
    public static final int MAIN=17;
    public static final int EMPTY_FIELD=18;

    // delegates
    // delegators


        public RuleParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public RuleParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return RuleParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g"; }


    public static class main_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "main"
    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:1: main : ( rule NEWLINE NEWLINE )* rule -> ^( MAIN ( rule )* ) ;
    public final RuleParser.main_return main() throws RecognitionException {
        RuleParser.main_return retval = new RuleParser.main_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE2=null;
        Token NEWLINE3=null;
        RuleParser.rule_return rule1 = null;

        RuleParser.rule_return rule4 = null;


        Object NEWLINE2_tree=null;
        Object NEWLINE3_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_rule=new RewriteRuleSubtreeStream(adaptor,"rule rule");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:5: ( ( rule NEWLINE NEWLINE )* rule -> ^( MAIN ( rule )* ) )
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:7: ( rule NEWLINE NEWLINE )* rule
            {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:7: ( rule NEWLINE NEWLINE )*
            loop1:
            do {
                int alt1=2;
                alt1 = dfa1.predict(input);
                switch (alt1) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:8: rule NEWLINE NEWLINE
            	    {
            	    pushFollow(FOLLOW_rule_in_main52);
            	    rule1=rule();

            	    state._fsp--;

            	    stream_rule.add(rule1.getTree());
            	    NEWLINE2=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_main54);  
            	    stream_NEWLINE.add(NEWLINE2);

            	    NEWLINE3=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_main56);  
            	    stream_NEWLINE.add(NEWLINE3);


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            pushFollow(FOLLOW_rule_in_main60);
            rule4=rule();

            state._fsp--;

            stream_rule.add(rule4.getTree());


            // AST REWRITE
            // elements: rule
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 15:36: -> ^( MAIN ( rule )* )
            {
                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:39: ^( MAIN ( rule )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(MAIN, "MAIN"), root_1);

                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:46: ( rule )*
                while ( stream_rule.hasNext() ) {
                    adaptor.addChild(root_1, stream_rule.nextTree());

                }
                stream_rule.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class rule_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "rule"
    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:1: rule : lhs= pattern NEWLINE TO NEWLINE rhs= pattern -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) ) ;
    public final RuleParser.rule_return rule() throws RecognitionException {
        RuleParser.rule_return retval = new RuleParser.rule_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE5=null;
        Token TO6=null;
        Token NEWLINE7=null;
        RuleParser.pattern_return lhs = null;

        RuleParser.pattern_return rhs = null;


        Object NEWLINE5_tree=null;
        Object TO6_tree=null;
        Object NEWLINE7_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleTokenStream stream_TO=new RewriteRuleTokenStream(adaptor,"token TO");
        RewriteRuleSubtreeStream stream_pattern=new RewriteRuleSubtreeStream(adaptor,"rule pattern");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:5: (lhs= pattern NEWLINE TO NEWLINE rhs= pattern -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) ) )
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:7: lhs= pattern NEWLINE TO NEWLINE rhs= pattern
            {
            pushFollow(FOLLOW_pattern_in_rule78);
            lhs=pattern();

            state._fsp--;

            stream_pattern.add(lhs.getTree());
            NEWLINE5=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_rule80);  
            stream_NEWLINE.add(NEWLINE5);

            TO6=(Token)match(input,TO,FOLLOW_TO_in_rule82);  
            stream_TO.add(TO6);

            NEWLINE7=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_rule84);  
            stream_NEWLINE.add(NEWLINE7);

            pushFollow(FOLLOW_pattern_in_rule88);
            rhs=pattern();

            state._fsp--;

            stream_pattern.add(rhs.getTree());


            // AST REWRITE
            // elements: rhs, lhs
            // token labels: 
            // rule labels: retval, rhs, lhs
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_rhs=new RewriteRuleSubtreeStream(adaptor,"rule rhs",rhs!=null?rhs.tree:null);
            RewriteRuleSubtreeStream stream_lhs=new RewriteRuleSubtreeStream(adaptor,"rule lhs",lhs!=null?lhs.tree:null);

            root_0 = (Object)adaptor.nil();
            // 17:50: -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) )
            {
                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:53: ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RULE, "RULE"), root_1);

                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:60: ^( BEFORE $lhs)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(BEFORE, "BEFORE"), root_2);

                adaptor.addChild(root_2, stream_lhs.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:75: ^( AFTER $rhs)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(AFTER, "AFTER"), root_2);

                adaptor.addChild(root_2, stream_rhs.nextTree());

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "rule"

    public static class pattern_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "pattern"
    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:1: pattern : ( row NEWLINE )* row -> ( row )+ ;
    public final RuleParser.pattern_return pattern() throws RecognitionException {
        RuleParser.pattern_return retval = new RuleParser.pattern_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE9=null;
        RuleParser.row_return row8 = null;

        RuleParser.row_return row10 = null;


        Object NEWLINE9_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_row=new RewriteRuleSubtreeStream(adaptor,"rule row");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:8: ( ( row NEWLINE )* row -> ( row )+ )
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:10: ( row NEWLINE )* row
            {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:10: ( row NEWLINE )*
            loop2:
            do {
                int alt2=2;
                alt2 = dfa2.predict(input);
                switch (alt2) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:11: row NEWLINE
            	    {
            	    pushFollow(FOLLOW_row_in_pattern116);
            	    row8=row();

            	    state._fsp--;

            	    stream_row.add(row8.getTree());
            	    NEWLINE9=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_pattern118);  
            	    stream_NEWLINE.add(NEWLINE9);


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            pushFollow(FOLLOW_row_in_pattern122);
            row10=row();

            state._fsp--;

            stream_row.add(row10.getTree());


            // AST REWRITE
            // elements: row
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 19:29: -> ( row )+
            {
                if ( !(stream_row.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_row.hasNext() ) {
                    adaptor.addChild(root_0, stream_row.nextTree());

                }
                stream_row.reset();

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "pattern"

    public static class row_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "row"
    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:1: row : ( tile SEPARATOR )* tile -> ^( ROW ( tile )+ ) ;
    public final RuleParser.row_return row() throws RecognitionException {
        RuleParser.row_return retval = new RuleParser.row_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token SEPARATOR12=null;
        RuleParser.tile_return tile11 = null;

        RuleParser.tile_return tile13 = null;


        Object SEPARATOR12_tree=null;
        RewriteRuleTokenStream stream_SEPARATOR=new RewriteRuleTokenStream(adaptor,"token SEPARATOR");
        RewriteRuleSubtreeStream stream_tile=new RewriteRuleSubtreeStream(adaptor,"rule tile");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:4: ( ( tile SEPARATOR )* tile -> ^( ROW ( tile )+ ) )
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:7: ( tile SEPARATOR )* tile
            {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:7: ( tile SEPARATOR )*
            loop3:
            do {
                int alt3=2;
                switch ( input.LA(1) ) {
                case THIS:
                    {
                    int LA3_1 = input.LA(2);

                    if ( (LA3_1==SEPARATOR) ) {
                        alt3=1;
                    }


                    }
                    break;
                case DONTCARE:
                    {
                    int LA3_2 = input.LA(2);

                    if ( (LA3_2==SEPARATOR) ) {
                        alt3=1;
                    }


                    }
                    break;
                case EMPTY:
                    {
                    int LA3_3 = input.LA(2);

                    if ( (LA3_3==SEPARATOR) ) {
                        alt3=1;
                    }


                    }
                    break;

                }

                switch (alt3) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:8: tile SEPARATOR
            	    {
            	    pushFollow(FOLLOW_tile_in_row136);
            	    tile11=tile();

            	    state._fsp--;

            	    stream_tile.add(tile11.getTree());
            	    SEPARATOR12=(Token)match(input,SEPARATOR,FOLLOW_SEPARATOR_in_row138);  
            	    stream_SEPARATOR.add(SEPARATOR12);


            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);

            pushFollow(FOLLOW_tile_in_row142);
            tile13=tile();

            state._fsp--;

            stream_tile.add(tile13.getTree());


            // AST REWRITE
            // elements: tile
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 21:31: -> ^( ROW ( tile )+ )
            {
                // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:34: ^( ROW ( tile )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ROW, "ROW"), root_1);

                if ( !(stream_tile.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_tile.hasNext() ) {
                    adaptor.addChild(root_1, stream_tile.nextTree());

                }
                stream_tile.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "row"

    public static class tile_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "tile"
    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:1: tile : ( THIS -> ^( THIS_FIELD ) | DONTCARE -> ^( DONTCARE_FIELD ) | EMPTY -> ^( EMPTY_FIELD ) );
    public final RuleParser.tile_return tile() throws RecognitionException {
        RuleParser.tile_return retval = new RuleParser.tile_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token THIS14=null;
        Token DONTCARE15=null;
        Token EMPTY16=null;

        Object THIS14_tree=null;
        Object DONTCARE15_tree=null;
        Object EMPTY16_tree=null;
        RewriteRuleTokenStream stream_DONTCARE=new RewriteRuleTokenStream(adaptor,"token DONTCARE");
        RewriteRuleTokenStream stream_EMPTY=new RewriteRuleTokenStream(adaptor,"token EMPTY");
        RewriteRuleTokenStream stream_THIS=new RewriteRuleTokenStream(adaptor,"token THIS");

        try {
            // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:5: ( THIS -> ^( THIS_FIELD ) | DONTCARE -> ^( DONTCARE_FIELD ) | EMPTY -> ^( EMPTY_FIELD ) )
            int alt4=3;
            switch ( input.LA(1) ) {
            case THIS:
                {
                alt4=1;
                }
                break;
            case DONTCARE:
                {
                alt4=2;
                }
                break;
            case EMPTY:
                {
                alt4=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 4, 0, input);

                throw nvae;
            }

            switch (alt4) {
                case 1 :
                    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:7: THIS
                    {
                    THIS14=(Token)match(input,THIS,FOLLOW_THIS_in_tile159);  
                    stream_THIS.add(THIS14);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 23:12: -> ^( THIS_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:15: ^( THIS_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(THIS_FIELD, "THIS_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:31: DONTCARE
                    {
                    DONTCARE15=(Token)match(input,DONTCARE,FOLLOW_DONTCARE_in_tile169);  
                    stream_DONTCARE.add(DONTCARE15);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 23:40: -> ^( DONTCARE_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:43: ^( DONTCARE_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(DONTCARE_FIELD, "DONTCARE_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 3 :
                    // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:63: EMPTY
                    {
                    EMPTY16=(Token)match(input,EMPTY,FOLLOW_EMPTY_in_tile179);  
                    stream_EMPTY.add(EMPTY16);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 23:69: -> ^( EMPTY_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex3\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:72: ^( EMPTY_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(EMPTY_FIELD, "EMPTY_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "tile"

    // Delegated rules


    protected DFA1 dfa1 = new DFA1(this);
    protected DFA2 dfa2 = new DFA2(this);
    static final String DFA1_eotS =
        "\17\uffff";
    static final String DFA1_eofS =
        "\10\uffff\3\15\4\uffff";
    static final String DFA1_minS =
        "\1\6\3\10\1\6\1\5\1\11\1\6\3\10\2\6\2\uffff";
    static final String DFA1_maxS =
        "\1\12\3\11\2\12\1\11\1\12\3\11\2\12\2\uffff";
    static final String DFA1_acceptS =
        "\15\uffff\1\2\1\1";
    static final String DFA1_specialS =
        "\17\uffff}>";
    static final String[] DFA1_transitionS = {
            "\1\2\1\1\2\uffff\1\3",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\2\1\1\2\uffff\1\3",
            "\1\6\1\2\1\1\2\uffff\1\3",
            "\1\7",
            "\1\11\1\10\2\uffff\1\12",
            "\1\13\1\14",
            "\1\13\1\14",
            "\1\13\1\14",
            "\1\11\1\10\2\uffff\1\12",
            "\1\11\1\10\1\uffff\1\16\1\12",
            "",
            ""
    };

    static final short[] DFA1_eot = DFA.unpackEncodedString(DFA1_eotS);
    static final short[] DFA1_eof = DFA.unpackEncodedString(DFA1_eofS);
    static final char[] DFA1_min = DFA.unpackEncodedStringToUnsignedChars(DFA1_minS);
    static final char[] DFA1_max = DFA.unpackEncodedStringToUnsignedChars(DFA1_maxS);
    static final short[] DFA1_accept = DFA.unpackEncodedString(DFA1_acceptS);
    static final short[] DFA1_special = DFA.unpackEncodedString(DFA1_specialS);
    static final short[][] DFA1_transition;

    static {
        int numStates = DFA1_transitionS.length;
        DFA1_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA1_transition[i] = DFA.unpackEncodedString(DFA1_transitionS[i]);
        }
    }

    class DFA1 extends DFA {

        public DFA1(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 1;
            this.eot = DFA1_eot;
            this.eof = DFA1_eof;
            this.min = DFA1_min;
            this.max = DFA1_max;
            this.accept = DFA1_accept;
            this.special = DFA1_special;
            this.transition = DFA1_transition;
        }
        public String getDescription() {
            return "()* loopback of 15:7: ( rule NEWLINE NEWLINE )*";
        }
    }
    static final String DFA2_eotS =
        "\10\uffff";
    static final String DFA2_eofS =
        "\1\uffff\3\6\4\uffff";
    static final String DFA2_minS =
        "\1\6\3\10\1\6\1\5\2\uffff";
    static final String DFA2_maxS =
        "\1\12\3\11\2\12\2\uffff";
    static final String DFA2_acceptS =
        "\6\uffff\1\2\1\1";
    static final String DFA2_specialS =
        "\10\uffff}>";
    static final String[] DFA2_transitionS = {
            "\1\2\1\1\2\uffff\1\3",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\2\1\1\2\uffff\1\3",
            "\1\6\2\7\1\uffff\1\6\1\7",
            "",
            ""
    };

    static final short[] DFA2_eot = DFA.unpackEncodedString(DFA2_eotS);
    static final short[] DFA2_eof = DFA.unpackEncodedString(DFA2_eofS);
    static final char[] DFA2_min = DFA.unpackEncodedStringToUnsignedChars(DFA2_minS);
    static final char[] DFA2_max = DFA.unpackEncodedStringToUnsignedChars(DFA2_maxS);
    static final short[] DFA2_accept = DFA.unpackEncodedString(DFA2_acceptS);
    static final short[] DFA2_special = DFA.unpackEncodedString(DFA2_specialS);
    static final short[][] DFA2_transition;

    static {
        int numStates = DFA2_transitionS.length;
        DFA2_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA2_transition[i] = DFA.unpackEncodedString(DFA2_transitionS[i]);
        }
    }

    class DFA2 extends DFA {

        public DFA2(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 2;
            this.eot = DFA2_eot;
            this.eof = DFA2_eof;
            this.min = DFA2_min;
            this.max = DFA2_max;
            this.accept = DFA2_accept;
            this.special = DFA2_special;
            this.transition = DFA2_transition;
        }
        public String getDescription() {
            return "()* loopback of 19:10: ( row NEWLINE )*";
        }
    }
 

    public static final BitSet FOLLOW_rule_in_main52 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_NEWLINE_in_main54 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_NEWLINE_in_main56 = new BitSet(new long[]{0x00000000000004C0L});
    public static final BitSet FOLLOW_rule_in_main60 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_pattern_in_rule78 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_NEWLINE_in_rule80 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_TO_in_rule82 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_NEWLINE_in_rule84 = new BitSet(new long[]{0x00000000000004C0L});
    public static final BitSet FOLLOW_pattern_in_rule88 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_row_in_pattern116 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_NEWLINE_in_pattern118 = new BitSet(new long[]{0x00000000000004C0L});
    public static final BitSet FOLLOW_row_in_pattern122 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_tile_in_row136 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_SEPARATOR_in_row138 = new BitSet(new long[]{0x00000000000004C0L});
    public static final BitSet FOLLOW_tile_in_row142 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_THIS_in_tile159 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DONTCARE_in_tile169 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_EMPTY_in_tile179 = new BitSet(new long[]{0x0000000000000002L});

}